﻿/**  版本信息模板在安装目录下，可自行修改。
* Products.cs
*
* 功 能： N/A
* 类 名： Products
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2016/9/6 22:23:30   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace Maticsoft.DAL
{
	/// <summary>
	/// 数据访问类:Products
	/// </summary>
	public partial class Products
	{
		public Products()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("ProductId", "Products"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int ProductId)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from Products");
			strSql.Append(" where ProductId=@ProductId");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductId", SqlDbType.Int,4)
			};
			parameters[0].Value = ProductId;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(Maticsoft.Model.Products model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Products(");
			strSql.Append("ProductName,ProductNo,CategoryId,Layout,SalePrice,MarketPrice,DollarsPrice,Size,Publisher,Storer,ShipFeeDesc,ShipFee,InsureFee,TaxFee,Weight,NetWeight,Summary,Detail,DetailWap,CreateTime,UpdateTime,IsActive,OrderNo,StoreNum,MaxNum,MinNum,SaleNum,CommentNum,Hits,Pic,IsHot,IsGood,IsHotSale,IsTop,IsHid,IsHidWap,FactoryNo)");
			strSql.Append(" values (");
			strSql.Append("@ProductName,@ProductNo,@CategoryId,@Layout,@SalePrice,@MarketPrice,@DollarsPrice,@Size,@Publisher,@Storer,@ShipFeeDesc,@ShipFee,@InsureFee,@TaxFee,@Weight,@NetWeight,@Summary,@Detail,@DetailWap,@CreateTime,@UpdateTime,@IsActive,@OrderNo,@StoreNum,@MaxNum,@MinNum,@SaleNum,@CommentNum,@Hits,@Pic,@IsHot,@IsGood,@IsHotSale,@IsTop,@IsHid,@IsHidWap,@FactoryNo)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductName", SqlDbType.NVarChar,100),
					new SqlParameter("@ProductNo", SqlDbType.VarChar,50),
					new SqlParameter("@CategoryId", SqlDbType.Int,4),
					new SqlParameter("@Layout", SqlDbType.NVarChar,500),
					new SqlParameter("@SalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MarketPrice", SqlDbType.Decimal,9),
					new SqlParameter("@DollarsPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Size", SqlDbType.NVarChar,50),
					new SqlParameter("@Publisher", SqlDbType.NVarChar,100),
					new SqlParameter("@Storer", SqlDbType.NVarChar,100),
					new SqlParameter("@ShipFeeDesc", SqlDbType.NVarChar,100),
					new SqlParameter("@ShipFee", SqlDbType.Decimal,9),
					new SqlParameter("@InsureFee", SqlDbType.Decimal,9),
					new SqlParameter("@TaxFee", SqlDbType.Decimal,9),
					new SqlParameter("@Weight", SqlDbType.Int,4),
					new SqlParameter("@NetWeight", SqlDbType.Int,4),
					new SqlParameter("@Summary", SqlDbType.NText),
					new SqlParameter("@Detail", SqlDbType.NText),
					new SqlParameter("@DetailWap", SqlDbType.NText),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@UpdateTime", SqlDbType.DateTime),
					new SqlParameter("@IsActive", SqlDbType.Int,4),
					new SqlParameter("@OrderNo", SqlDbType.Int,4),
					new SqlParameter("@StoreNum", SqlDbType.Int,4),
					new SqlParameter("@MaxNum", SqlDbType.Int,4),
					new SqlParameter("@MinNum", SqlDbType.Int,4),
					new SqlParameter("@SaleNum", SqlDbType.Int,4),
					new SqlParameter("@CommentNum", SqlDbType.Int,4),
					new SqlParameter("@Hits", SqlDbType.Int,4),
					new SqlParameter("@Pic", SqlDbType.VarChar,200),
					new SqlParameter("@IsHot", SqlDbType.Int,4),
					new SqlParameter("@IsGood", SqlDbType.Int,4),
					new SqlParameter("@IsHotSale", SqlDbType.Int,4),
					new SqlParameter("@IsTop", SqlDbType.Int,4),
					new SqlParameter("@IsHid", SqlDbType.Int,4),
					new SqlParameter("@IsHidWap", SqlDbType.Int,4),
					new SqlParameter("@FactoryNo", SqlDbType.VarChar,50)};
			parameters[0].Value = model.ProductName;
			parameters[1].Value = model.ProductNo;
			parameters[2].Value = model.CategoryId;
			parameters[3].Value = model.Layout;
			parameters[4].Value = model.SalePrice;
			parameters[5].Value = model.MarketPrice;
			parameters[6].Value = model.DollarsPrice;
			parameters[7].Value = model.Size;
			parameters[8].Value = model.Publisher;
			parameters[9].Value = model.Storer;
			parameters[10].Value = model.ShipFeeDesc;
			parameters[11].Value = model.ShipFee;
			parameters[12].Value = model.InsureFee;
			parameters[13].Value = model.TaxFee;
			parameters[14].Value = model.Weight;
			parameters[15].Value = model.NetWeight;
			parameters[16].Value = model.Summary;
			parameters[17].Value = model.Detail;
			parameters[18].Value = model.DetailWap;
			parameters[19].Value = model.CreateTime;
			parameters[20].Value = model.UpdateTime;
			parameters[21].Value = model.IsActive;
			parameters[22].Value = model.OrderNo;
			parameters[23].Value = model.StoreNum;
			parameters[24].Value = model.MaxNum;
			parameters[25].Value = model.MinNum;
			parameters[26].Value = model.SaleNum;
			parameters[27].Value = model.CommentNum;
			parameters[28].Value = model.Hits;
			parameters[29].Value = model.Pic;
			parameters[30].Value = model.IsHot;
			parameters[31].Value = model.IsGood;
			parameters[32].Value = model.IsHotSale;
			parameters[33].Value = model.IsTop;
			parameters[34].Value = model.IsHid;
			parameters[35].Value = model.IsHidWap;
			parameters[36].Value = model.FactoryNo;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Maticsoft.Model.Products model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Products set ");
			strSql.Append("ProductName=@ProductName,");
			strSql.Append("ProductNo=@ProductNo,");
			strSql.Append("CategoryId=@CategoryId,");
			strSql.Append("Layout=@Layout,");
			strSql.Append("SalePrice=@SalePrice,");
			strSql.Append("MarketPrice=@MarketPrice,");
			strSql.Append("DollarsPrice=@DollarsPrice,");
			strSql.Append("Size=@Size,");
			strSql.Append("Publisher=@Publisher,");
			strSql.Append("Storer=@Storer,");
			strSql.Append("ShipFeeDesc=@ShipFeeDesc,");
			strSql.Append("ShipFee=@ShipFee,");
			strSql.Append("InsureFee=@InsureFee,");
			strSql.Append("TaxFee=@TaxFee,");
			strSql.Append("Weight=@Weight,");
			strSql.Append("NetWeight=@NetWeight,");
			strSql.Append("Summary=@Summary,");
			strSql.Append("Detail=@Detail,");
			strSql.Append("DetailWap=@DetailWap,");
			strSql.Append("CreateTime=@CreateTime,");
			strSql.Append("UpdateTime=@UpdateTime,");
			strSql.Append("IsActive=@IsActive,");
			strSql.Append("OrderNo=@OrderNo,");
			strSql.Append("StoreNum=@StoreNum,");
			strSql.Append("MaxNum=@MaxNum,");
			strSql.Append("MinNum=@MinNum,");
			strSql.Append("SaleNum=@SaleNum,");
			strSql.Append("CommentNum=@CommentNum,");
			strSql.Append("Hits=@Hits,");
			strSql.Append("Pic=@Pic,");
			strSql.Append("IsHot=@IsHot,");
			strSql.Append("IsGood=@IsGood,");
			strSql.Append("IsHotSale=@IsHotSale,");
			strSql.Append("IsTop=@IsTop,");
			strSql.Append("IsHid=@IsHid,");
			strSql.Append("IsHidWap=@IsHidWap,");
			strSql.Append("FactoryNo=@FactoryNo");
			strSql.Append(" where ProductId=@ProductId");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductName", SqlDbType.NVarChar,100),
					new SqlParameter("@ProductNo", SqlDbType.VarChar,50),
					new SqlParameter("@CategoryId", SqlDbType.Int,4),
					new SqlParameter("@Layout", SqlDbType.NVarChar,500),
					new SqlParameter("@SalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MarketPrice", SqlDbType.Decimal,9),
					new SqlParameter("@DollarsPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Size", SqlDbType.NVarChar,50),
					new SqlParameter("@Publisher", SqlDbType.NVarChar,100),
					new SqlParameter("@Storer", SqlDbType.NVarChar,100),
					new SqlParameter("@ShipFeeDesc", SqlDbType.NVarChar,100),
					new SqlParameter("@ShipFee", SqlDbType.Decimal,9),
					new SqlParameter("@InsureFee", SqlDbType.Decimal,9),
					new SqlParameter("@TaxFee", SqlDbType.Decimal,9),
					new SqlParameter("@Weight", SqlDbType.Int,4),
					new SqlParameter("@NetWeight", SqlDbType.Int,4),
					new SqlParameter("@Summary", SqlDbType.NText),
					new SqlParameter("@Detail", SqlDbType.NText),
					new SqlParameter("@DetailWap", SqlDbType.NText),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@UpdateTime", SqlDbType.DateTime),
					new SqlParameter("@IsActive", SqlDbType.Int,4),
					new SqlParameter("@OrderNo", SqlDbType.Int,4),
					new SqlParameter("@StoreNum", SqlDbType.Int,4),
					new SqlParameter("@MaxNum", SqlDbType.Int,4),
					new SqlParameter("@MinNum", SqlDbType.Int,4),
					new SqlParameter("@SaleNum", SqlDbType.Int,4),
					new SqlParameter("@CommentNum", SqlDbType.Int,4),
					new SqlParameter("@Hits", SqlDbType.Int,4),
					new SqlParameter("@Pic", SqlDbType.VarChar,200),
					new SqlParameter("@IsHot", SqlDbType.Int,4),
					new SqlParameter("@IsGood", SqlDbType.Int,4),
					new SqlParameter("@IsHotSale", SqlDbType.Int,4),
					new SqlParameter("@IsTop", SqlDbType.Int,4),
					new SqlParameter("@IsHid", SqlDbType.Int,4),
					new SqlParameter("@IsHidWap", SqlDbType.Int,4),
					new SqlParameter("@FactoryNo", SqlDbType.VarChar,50),
					new SqlParameter("@ProductId", SqlDbType.Int,4)};
			parameters[0].Value = model.ProductName;
			parameters[1].Value = model.ProductNo;
			parameters[2].Value = model.CategoryId;
			parameters[3].Value = model.Layout;
			parameters[4].Value = model.SalePrice;
			parameters[5].Value = model.MarketPrice;
			parameters[6].Value = model.DollarsPrice;
			parameters[7].Value = model.Size;
			parameters[8].Value = model.Publisher;
			parameters[9].Value = model.Storer;
			parameters[10].Value = model.ShipFeeDesc;
			parameters[11].Value = model.ShipFee;
			parameters[12].Value = model.InsureFee;
			parameters[13].Value = model.TaxFee;
			parameters[14].Value = model.Weight;
			parameters[15].Value = model.NetWeight;
			parameters[16].Value = model.Summary;
			parameters[17].Value = model.Detail;
			parameters[18].Value = model.DetailWap;
			parameters[19].Value = model.CreateTime;
			parameters[20].Value = model.UpdateTime;
			parameters[21].Value = model.IsActive;
			parameters[22].Value = model.OrderNo;
			parameters[23].Value = model.StoreNum;
			parameters[24].Value = model.MaxNum;
			parameters[25].Value = model.MinNum;
			parameters[26].Value = model.SaleNum;
			parameters[27].Value = model.CommentNum;
			parameters[28].Value = model.Hits;
			parameters[29].Value = model.Pic;
			parameters[30].Value = model.IsHot;
			parameters[31].Value = model.IsGood;
			parameters[32].Value = model.IsHotSale;
			parameters[33].Value = model.IsTop;
			parameters[34].Value = model.IsHid;
			parameters[35].Value = model.IsHidWap;
			parameters[36].Value = model.FactoryNo;
			parameters[37].Value = model.ProductId;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ProductId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Products ");
			strSql.Append(" where ProductId=@ProductId");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductId", SqlDbType.Int,4)
			};
			parameters[0].Value = ProductId;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string ProductIdlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Products ");
			strSql.Append(" where ProductId in ("+ProductIdlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Maticsoft.Model.Products GetModel(int ProductId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 ProductId,ProductName,ProductNo,CategoryId,Layout,SalePrice,MarketPrice,DollarsPrice,Size,Publisher,Storer,ShipFeeDesc,ShipFee,InsureFee,TaxFee,Weight,NetWeight,Summary,Detail,DetailWap,CreateTime,UpdateTime,IsActive,OrderNo,StoreNum,MaxNum,MinNum,SaleNum,CommentNum,Hits,Pic,IsHot,IsGood,IsHotSale,IsTop,IsHid,IsHidWap,FactoryNo from Products ");
			strSql.Append(" where ProductId=@ProductId");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductId", SqlDbType.Int,4)
			};
			parameters[0].Value = ProductId;

			Maticsoft.Model.Products model=new Maticsoft.Model.Products();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Maticsoft.Model.Products DataRowToModel(DataRow row)
		{
			Maticsoft.Model.Products model=new Maticsoft.Model.Products();
			if (row != null)
			{
				if(row["ProductId"]!=null && row["ProductId"].ToString()!="")
				{
					model.ProductId=int.Parse(row["ProductId"].ToString());
				}
				if(row["ProductName"]!=null)
				{
					model.ProductName=row["ProductName"].ToString();
				}
				if(row["ProductNo"]!=null)
				{
					model.ProductNo=row["ProductNo"].ToString();
				}
				if(row["CategoryId"]!=null && row["CategoryId"].ToString()!="")
				{
					model.CategoryId=int.Parse(row["CategoryId"].ToString());
				}
				if(row["Layout"]!=null)
				{
					model.Layout=row["Layout"].ToString();
				}
				if(row["SalePrice"]!=null && row["SalePrice"].ToString()!="")
				{
					model.SalePrice=decimal.Parse(row["SalePrice"].ToString());
				}
				if(row["MarketPrice"]!=null && row["MarketPrice"].ToString()!="")
				{
					model.MarketPrice=decimal.Parse(row["MarketPrice"].ToString());
				}
				if(row["DollarsPrice"]!=null && row["DollarsPrice"].ToString()!="")
				{
					model.DollarsPrice=decimal.Parse(row["DollarsPrice"].ToString());
				}
				if(row["Size"]!=null)
				{
					model.Size=row["Size"].ToString();
				}
				if(row["Publisher"]!=null)
				{
					model.Publisher=row["Publisher"].ToString();
				}
				if(row["Storer"]!=null)
				{
					model.Storer=row["Storer"].ToString();
				}
				if(row["ShipFeeDesc"]!=null)
				{
					model.ShipFeeDesc=row["ShipFeeDesc"].ToString();
				}
				if(row["ShipFee"]!=null && row["ShipFee"].ToString()!="")
				{
					model.ShipFee=decimal.Parse(row["ShipFee"].ToString());
				}
				if(row["InsureFee"]!=null && row["InsureFee"].ToString()!="")
				{
					model.InsureFee=decimal.Parse(row["InsureFee"].ToString());
				}
				if(row["TaxFee"]!=null && row["TaxFee"].ToString()!="")
				{
					model.TaxFee=decimal.Parse(row["TaxFee"].ToString());
				}
				if(row["Weight"]!=null && row["Weight"].ToString()!="")
				{
					model.Weight=int.Parse(row["Weight"].ToString());
				}
				if(row["NetWeight"]!=null && row["NetWeight"].ToString()!="")
				{
					model.NetWeight=int.Parse(row["NetWeight"].ToString());
				}
				if(row["Summary"]!=null)
				{
					model.Summary=row["Summary"].ToString();
				}
				if(row["Detail"]!=null)
				{
					model.Detail=row["Detail"].ToString();
				}
				if(row["DetailWap"]!=null)
				{
					model.DetailWap=row["DetailWap"].ToString();
				}
				if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
				{
					model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
				}
				if(row["UpdateTime"]!=null && row["UpdateTime"].ToString()!="")
				{
					model.UpdateTime=DateTime.Parse(row["UpdateTime"].ToString());
				}
				if(row["IsActive"]!=null && row["IsActive"].ToString()!="")
				{
					model.IsActive=int.Parse(row["IsActive"].ToString());
				}
				if(row["OrderNo"]!=null && row["OrderNo"].ToString()!="")
				{
					model.OrderNo=int.Parse(row["OrderNo"].ToString());
				}
				if(row["StoreNum"]!=null && row["StoreNum"].ToString()!="")
				{
					model.StoreNum=int.Parse(row["StoreNum"].ToString());
				}
				if(row["MaxNum"]!=null && row["MaxNum"].ToString()!="")
				{
					model.MaxNum=int.Parse(row["MaxNum"].ToString());
				}
				if(row["MinNum"]!=null && row["MinNum"].ToString()!="")
				{
					model.MinNum=int.Parse(row["MinNum"].ToString());
				}
				if(row["SaleNum"]!=null && row["SaleNum"].ToString()!="")
				{
					model.SaleNum=int.Parse(row["SaleNum"].ToString());
				}
				if(row["CommentNum"]!=null && row["CommentNum"].ToString()!="")
				{
					model.CommentNum=int.Parse(row["CommentNum"].ToString());
				}
				if(row["Hits"]!=null && row["Hits"].ToString()!="")
				{
					model.Hits=int.Parse(row["Hits"].ToString());
				}
				if(row["Pic"]!=null)
				{
					model.Pic=row["Pic"].ToString();
				}
				if(row["IsHot"]!=null && row["IsHot"].ToString()!="")
				{
					model.IsHot=int.Parse(row["IsHot"].ToString());
				}
				if(row["IsGood"]!=null && row["IsGood"].ToString()!="")
				{
					model.IsGood=int.Parse(row["IsGood"].ToString());
				}
				if(row["IsHotSale"]!=null && row["IsHotSale"].ToString()!="")
				{
					model.IsHotSale=int.Parse(row["IsHotSale"].ToString());
				}
				if(row["IsTop"]!=null && row["IsTop"].ToString()!="")
				{
					model.IsTop=int.Parse(row["IsTop"].ToString());
				}
				if(row["IsHid"]!=null && row["IsHid"].ToString()!="")
				{
					model.IsHid=int.Parse(row["IsHid"].ToString());
				}
				if(row["IsHidWap"]!=null && row["IsHidWap"].ToString()!="")
				{
					model.IsHidWap=int.Parse(row["IsHidWap"].ToString());
				}
				if(row["FactoryNo"]!=null)
				{
					model.FactoryNo=row["FactoryNo"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ProductId,ProductName,ProductNo,CategoryId,Layout,SalePrice,MarketPrice,DollarsPrice,Size,Publisher,Storer,ShipFeeDesc,ShipFee,InsureFee,TaxFee,Weight,NetWeight,Summary,Detail,DetailWap,CreateTime,UpdateTime,IsActive,OrderNo,StoreNum,MaxNum,MinNum,SaleNum,CommentNum,Hits,Pic,IsHot,IsGood,IsHotSale,IsTop,IsHid,IsHidWap,FactoryNo ");
			strSql.Append(" FROM Products ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" ProductId,ProductName,ProductNo,CategoryId,Layout,SalePrice,MarketPrice,DollarsPrice,Size,Publisher,Storer,ShipFeeDesc,ShipFee,InsureFee,TaxFee,Weight,NetWeight,Summary,Detail,DetailWap,CreateTime,UpdateTime,IsActive,OrderNo,StoreNum,MaxNum,MinNum,SaleNum,CommentNum,Hits,Pic,IsHot,IsGood,IsHotSale,IsTop,IsHid,IsHidWap,FactoryNo ");
			strSql.Append(" FROM Products ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM Products ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.ProductId desc");
			}
			strSql.Append(")AS Row, T.*  from Products T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "Products";
			parameters[1].Value = "ProductId";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

